Skip to content

ORC-2164: [C++] Add external-buffer support in DataBuffer lifecycle management#2617

Closed
lucasfang wants to merge 2 commits into
apache:mainfrom
lucasfang:mempool
Closed

ORC-2164: [C++] Add external-buffer support in DataBuffer lifecycle management#2617
lucasfang wants to merge 2 commits into
apache:mainfrom
lucasfang:mempool

Conversation

@lucasfang
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR adds non-owning buffer support to DataBuffer so it can attach externally managed memory (via setData) without taking ownership of allocation/free, updates reserve/resize/destructor paths to be ownership-aware, and adds a focused unit test to verify that non-owning buffers keep external size semantics and do not free external memory during destruction.

Why are the changes needed?

These changes are needed to safely integrate with external prebuffer cache scenarios where memory is managed outside ORC, avoiding unnecessary reallocations and preventing ownership/lifecycle mismatches.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: GPT-5.3-codex

Copilot AI review requested due to automatic review settings May 7, 2026 06:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds non-owning (external) buffer attachment support to DataBuffer so it can reference externally managed memory without freeing it, and adjusts lifecycle methods accordingly.

Changes:

  • Introduces ownBuffer_ tracking in DataBuffer and updates destructor / reserve / resize to be ownership-aware.
  • Adds DataBuffer::setData() to attach an external raw buffer (non-owning).
  • Adds a unit test verifying external buffer size semantics and that external memory isn’t freed on destruction.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
c++/include/orc/MemoryPool.hh Extends DataBuffer API with ownership flag and setData() declaration.
c++/src/MemoryPool.cc Implements ownership-aware lifecycle behavior and setData() logic.
c++/test/TestCache.cc Adds a focused unit test for non-owning external buffers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread c++/test/TestCache.cc
Comment thread c++/src/MemoryPool.cc
Comment thread c++/src/MemoryPool.cc
Comment thread c++/include/orc/MemoryPool.hh
@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented May 7, 2026

Thanks for your contribution! Just FYI that I just fixed the Windows CI. Please rebase to avoid confusion :)

Copy link
Copy Markdown
Member

@wgtmac wgtmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving this! Would you mind creating a JIRA issue for this?

@lucasfang lucasfang changed the title [C++] Add external-buffer support in DataBuffer lifecycle management ORC-2164: [C++] Add external-buffer support in DataBuffer lifecycle management May 11, 2026
@wgtmac wgtmac closed this in fbc8c87 May 12, 2026
@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented May 12, 2026

Thank you, @lucasfang!

wgtmac pushed a commit that referenced this pull request May 12, 2026
…anagement

### What changes were proposed in this pull request?

This PR adds non-owning buffer support to DataBuffer so it can attach externally managed memory (via setData) without taking ownership of allocation/free, updates reserve/resize/destructor paths to be ownership-aware, and adds a focused unit test to verify that non-owning buffers keep external size semantics and do not free external memory during destruction.

### Why are the changes needed?

These changes are needed to safely integrate with external prebuffer cache scenarios where memory is managed outside ORC, avoiding unnecessary reallocations and preventing ownership/lifecycle mismatches.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: GPT-5.3-codex

Closes #2617 from lucasfang/mempool.

Authored-by: yonghao.fyh <yonghao.fyh@alibaba-inc.com>
Signed-off-by: Gang Wu <ustcwg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants